// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Widgets/SCompoundWidget.h"
#include "Widgets/Views/SListView.h"
#include "HotPakerType.h"

struct FAssetData;

DECLARE_DELEGATE_OneParam(FSelectAssetsChangeDelegate, TArray<FName>)

/**
 * 
 */
class SPakAssetsView : public SCompoundWidget
{
public:
	SLATE_BEGIN_ARGS(SPakAssetsView)
	{}
	SLATE_END_ARGS()

	/** Constructs this widget with InArgs */
	void Construct(const FArguments& InArgs);

	void AssignAssetList(TArray<FAssetData> AssetDatas);

	const TArray<FName>& GetAllSelectAssets();

	void AddSelectAsset(const FName& InPackageName);

	void RemoveSelectAsset(const FName& InPackageName);

	bool IsDependenceSelected(const FName& InPackageName);

	FReply SelectAllAssets();

	FReply SelectRootAssets();

	FReply ClearSelectAssets();

public:

	FSelectAssetsChangeDelegate SelectAssetsChangeDelegate;

protected:

	TSharedRef<ITableRow> HandleAssetViewGenerateRow(FAssetDetailNode_Ref AssetDetailNode, const TSharedRef<STableViewBase>& OwnerTable);

	void HandleAssetViewGetChildren(FAssetDetailNode_Ref AssetDetailNode, TArray<FAssetDetailNode_Ref>& OutDependencies);

	bool IsReferencedByOtherAsset(FName PackageName);



protected:

	TArray<FAssetDetailNode_Ref> AssetList;

	TArray<FName> SelectAssets;

	TSharedPtr<SAssetsViewTree> AssetViewTree;

};
